#pragma once

#include <stdio.h>

namespace factory {
    
/// @brief 抽象产品 - 定义了产品的规范，描述了产品的主要特性和功能
class AbstractProduct {
public:
    virtual ~AbstractProduct() {}
    virtual void Show() = 0;
};

/// @brief 具体产品 - 实现了抽象产品角色所定义的接口，由具体工厂来创建，它同具体工厂之间一一对应
class ConcreteProduct : public AbstractProduct {
public:
    virtual void Show() {
        printf("ConcreteProduct Show ...\n");
    }
};

/// @brief 抽象工厂 - 提供了创建产品的接口
class AbstractFactory {
public:
    virtual ~AbstractFactory() {}
    virtual AbstractProduct* CreateProduct() = 0;
};

/// @brief 具体工厂 - 实现抽象工厂中的抽象方法，完成具体产品的创建
class ConcreteFactory : public AbstractFactory {
public:
    virtual AbstractProduct* CreateProduct() {
        AbstractProduct* ptr = new ConcreteProduct();
        return ptr;
    }
};

} // namespace factory 

void Test_03_factory_impl_1() {
    printf("-------------------- %s --------------------\n", __FUNCTION__);
    factory::AbstractFactory* ptr_factory = new factory::ConcreteFactory();
    factory::AbstractProduct* ptr_product = ptr_factory->CreateProduct();
    ptr_product->Show();
    delete ptr_factory;
    delete ptr_product;
}

// -------------------- Test_03_factory_impl_1 --------------------
// ConcreteProduct Show ...